﻿package cocoaas3{

	import flash.display.*;
	import flash.geom.*;
	import flash.events.*;
	import flash.text.*;


	public class UINavigationItem extends EventDispatcher{
		
		//
		//-------------------------------------------------------------------------------------------
		// original variables
		//-------------------------------------------------------------------------------------------
		//
		private var _title:String;
		public function set title( val:String ):void{
			_title = val;
			this.dispatchEvent( new Event("onTitleChange") );
		}
		public function get title():String{
			return _title
		}

		public var titleView:MovieClip;// ここにナビバーに表示させたい Sprite を代入しておくと、紐付く UIViewController を表示した時に一緒に表示されます。
		public var hidesBackButton:Boolean = false;
		public var backBarButtonItem:UIBarButtonItem;
		public var rightBarButtonItem:UIBarButtonItem;


		//
		//-------------------------------------------------------------------------------------------
		// custom variables
		//-------------------------------------------------------------------------------------------
		//

		// デフォルトの backBarButtonItem
		static public var defaultBackBarImageClass:Class;
		static public function getDefaultBackBarButtonItem():UIBarButtonItem{
			if( defaultBackBarImageClass ){
				return new UIBarButtonItem( new defaultBackBarImageClass() );
			} else {
				return new UIBarButtonItem( new SampleBackButton() );
			}
		}


		//
		//-------------------------------------------------------------------------------------------
		// original functions
		//-------------------------------------------------------------------------------------------
		//

		public function UINavigationItem( $title:String ){
			title = $title;
		}


		//
		//-------------------------------------------------------------------------------------------
		// custom functions
		//-------------------------------------------------------------------------------------------
		//



	}
}



import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.text.*;

class SampleBackButton extends Sprite{
	public function SampleBackButton(){
		var shape = new Shape();
		var g:Graphics = shape.graphics;
		g.beginFill( 0xFF0000, 1 );	// 面のスタイル設定
		g.drawRect( 0, 0, 50, 50 );
		addChild( shape );
	}
}





